package com.shiminghui.String;

public class PinJieZiFuChuang {
    public static void main(String[] args) {
        int[] arr = {1, 2, 3, 4, 5};
        System.out.println(toString(arr));
    }

    public static String toString(int[] arr) {
        String result = "";
        if (arr.length == 0) {
            return "[]";
        }

        for (int i = 0; i < arr.length; i++) {
            if (i == 0) {
                result = result + "[" + arr[i] + ",";
            } else if (i == arr.length - 1) {
                result = result + arr[i] + "]";
            } else {
                result = result + arr[i] + ",";
            }
        }
        return result;
    }

}
